/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FormMenuTambah.java
 *
 * Created on Nov 11, 2012, 4:03:12 AM
 */
package com.rekap;

/**
 *
 * @author Satellite
 */
import com.view.*;
import com.model.*;
import java.sql.Connection;
import javax.activation.DataHandler;
import javax.swing.JOptionPane;

public class FormMenuTambah extends javax.swing.JFrame {

    /**
     * Creates new form FormMenuTambah
     */
    public FormMenuTambah() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel11 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jLayeredPane1 = new javax.swing.JLayeredPane();
        jLayeredPane2 = new javax.swing.JLayeredPane();
        jLayeredPane6 = new javax.swing.JLayeredPane();
        jLabel5 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jComboBox2 = new javax.swing.JComboBox();
        jComboBox3 = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jComboBox4 = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        jComboBox5 = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jLayeredPane3 = new javax.swing.JLayeredPane();
        jLayeredPane4 = new javax.swing.JLayeredPane();
        jLayeredPane5 = new javax.swing.JLayeredPane();
        jLabel1 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        file = new javax.swing.JMenu();
        home = new javax.swing.JMenuItem();
        exit = new javax.swing.JMenu();
        menuEdit = new javax.swing.JMenu();
        order = new javax.swing.JMenuItem();
        lihatPesanan = new javax.swing.JMenuItem();
        paket = new javax.swing.JMenu();
        lihatDaftarPaket = new javax.swing.JMenuItem();
        tambahPaket = new javax.swing.JMenuItem();
        member = new javax.swing.JMenu();
        lihatMember = new javax.swing.JMenuItem();
        tambahMember = new javax.swing.JMenuItem();

        jLabel11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/images/background.jpg"))); // NOI18N

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel10.setForeground(new java.awt.Color(0, 0, 255));
        jLabel10.setText("Tambah Menu");
        getContentPane().add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 70, 120, 20));

        jButton1.setText("Simpan");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 220, -1, -1));
        getContentPane().add(jLayeredPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 120, -1, -1));

        jLayeredPane2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Tambahkan menu anda:"));
        jLayeredPane6.setBounds(0, 10, 0, 0);
        jLayeredPane2.add(jLayeredPane6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel5.setText("Nasi :");
        jLabel5.setBounds(20, 80, 90, 14);
        jLayeredPane2.add(jLabel5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] {"","Nasi Goreng", "Nasi Kuning", "Nasi Uduk", "Nasi Liwet" }));
        jComboBox1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jComboBox1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboBox1ItemStateChanged(evt);
            }
        });
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });
        jComboBox1.setBounds(120, 80, 185, 20);
        jLayeredPane2.add(jComboBox1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel6.setText("Lauk :");
        jLabel6.setBounds(20, 120, 90, 14);
        jLayeredPane2.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "","Dendeng", "Sate", "Opor", "Kambing Guling" }));
        jComboBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox2ActionPerformed(evt);
            }
        });
        jComboBox2.setBounds(120, 120, 185, 20);
        jLayeredPane2.add(jComboBox2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "","Sup", "Sayur Lodeh", "Sayur Asem", "Bayam" }));
        jComboBox3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox3ActionPerformed(evt);
            }
        });
        jComboBox3.setBounds(120, 160, 185, 20);
        jLayeredPane2.add(jComboBox3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel7.setText("Sayur :");
        jLabel7.setBounds(20, 160, 90, 14);
        jLayeredPane2.add(jLabel7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel8.setText("Krupuk :");
        jLabel8.setBounds(20, 200, 90, 14);
        jLayeredPane2.add(jLabel8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] {"", "Krupuk Udang", "Rambak", "Krupuk Tulang", "Sikil" }));
        jComboBox4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox4ActionPerformed(evt);
            }
        });
        jComboBox4.setBounds(120, 200, 185, 20);
        jLayeredPane2.add(jComboBox4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel9.setText("Minum :");
        jLabel9.setBounds(20, 240, 90, 14);
        jLayeredPane2.add(jLabel9, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jComboBox5.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "","Air Putih", "Teh", "Susu", "Kopi" }));
        jComboBox5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox5ActionPerformed(evt);
            }
        });
        jComboBox5.setBounds(120, 240, 185, 20);
        jLayeredPane2.add(jComboBox5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel2.setText("Nama Paket:");
        jLabel2.setBounds(20, 20, 90, 14);
        jLayeredPane2.add(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel3.setText("Harga:");
        jLabel3.setBounds(20, 50, 90, 14);
        jLayeredPane2.add(jLabel3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });
        jTextField1.setBounds(120, 50, 190, 20);
        jLayeredPane2.add(jTextField1, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jTextField2.setBounds(120, 20, 190, 20);
        jLayeredPane2.add(jTextField2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        getContentPane().add(jLayeredPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 90, 360, 270));
        getContentPane().add(jLayeredPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 120, 330, 220));
        getContentPane().add(jLayeredPane4, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 110, 340, 230));
        getContentPane().add(jLayeredPane5, new org.netbeans.lib.awtextra.AbsoluteConstraints(31, 130, 350, 200));

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/images/background.jpg"))); // NOI18N
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        file.setText("File");

        home.setText("Home");
        home.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                homeActionPerformed(evt);
            }
        });
        file.add(home);

        exit.setText("Exit");
        exit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitActionPerformed(evt);
            }
        });
        file.add(exit);

        jMenuBar1.add(file);

        menuEdit.setText("Pesanan");

        order.setText("order");
        order.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                orderActionPerformed(evt);
            }
        });
        menuEdit.add(order);

        lihatPesanan.setText("lihat pesanan");
        lihatPesanan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lihatPesananActionPerformed(evt);
            }
        });
        menuEdit.add(lihatPesanan);

        jMenuBar1.add(menuEdit);

        paket.setText("Paket");

        lihatDaftarPaket.setText("lihat daftar Paket");
        lihatDaftarPaket.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lihatDaftarPaketActionPerformed(evt);
            }
        });
        paket.add(lihatDaftarPaket);

        tambahPaket.setText("tambah Paket");
        tambahPaket.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tambahPaketActionPerformed(evt);
            }
        });
        paket.add(tambahPaket);

        jMenuBar1.add(paket);

        member.setText("Member");

        lihatMember.setText("lihat Member");
        lihatMember.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lihatMemberActionPerformed(evt);
            }
        });
        member.add(lihatMember);

        tambahMember.setText("tambah Member");
        member.add(tambahMember);

        jMenuBar1.add(member);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        int[] count = {1, 2, 3, 4};
        int j = 0;
        for (int i = 0; i < count.length; i++) {
            j = count[i];

        }
        if (jComboBox1.getItemAt(j).equals("") && jComboBox2.getItemAt(j).equals("") && jComboBox3.getItemAt(j).equals("")
                && jComboBox4.getItemAt(j).equals("") && jComboBox5.getItemAt(j).equals("")) {
            JOptionPane.showMessageDialog(null, "Anda tidak memasukkan menu apapun");
 

        } else {
        }
                   Paket menu = new Paket();
            menu.setNamaPaket(jTextField2.getText());
            menu.setHargaPaket(Integer.parseInt(jTextField1.getText()));
            menu.setNasi((String) jComboBox1.getSelectedItem());
            menu.setLauk((String) jComboBox2.getSelectedItem());
            menu.setSayur((String) jComboBox3.getSelectedItem());
            menu.setKrupuk((String) jComboBox4.getSelectedItem());
            menu.setMinum((String) jComboBox5.getSelectedItem());
            try {
                TableKontrolPesanan.getKoneksiKategori().tambah(menu);
                JOptionPane.showMessageDialog(rootPane, "Berhasil masuk");
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(rootPane, "Data Gagal Dimasukkan \n error: " + ex.getMessage());
                ex.getMessage();
//            refresh();
            }
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBox1ActionPerformed

    private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBox1ItemStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBox1ItemStateChanged

    private void homeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_homeActionPerformed
        FromMenuOperator home = new FromMenuOperator();
        home.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_homeActionPerformed

    private void exitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitActionPerformed
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_exitActionPerformed

    private void orderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_orderActionPerformed
        FormPesanan pesan = new FormPesanan();
        pesan.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_orderActionPerformed

    private void lihatPesananActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lihatPesananActionPerformed
        view_pesanan viewp = new view_pesanan();
        viewp.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_lihatPesananActionPerformed

    private void lihatDaftarPaketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lihatDaftarPaketActionPerformed
        view_menu viewm = new view_menu();
        viewm.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_lihatDaftarPaketActionPerformed

    private void tambahPaketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tambahPaketActionPerformed
        FormMenuTambah addMenu = new FormMenuTambah();
        addMenu.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_tambahPaketActionPerformed

    private void lihatMemberActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lihatMemberActionPerformed
        view_member viewber = new view_member();
        viewber.setVisible(true);
        dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_lihatMemberActionPerformed

    private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBox2ActionPerformed

    private void jComboBox5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox5ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBox5ActionPerformed

    private void jComboBox4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBox4ActionPerformed

    private void jComboBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jComboBox3ActionPerformed

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
        angka(jTextField1.getText());
    }//GEN-LAST:event_jTextField1ActionPerformed
    public void angka(String angka) {
        if (!angka.matches("[0-9]*")) {
            JOptionPane.showMessageDialog(this, "Format salah Tolong Isikan angka");
            jTextField1.setText("");

        }
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FormMenuTambah().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu exit;
    private javax.swing.JMenu file;
    private javax.swing.JMenuItem home;
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JComboBox jComboBox5;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JLayeredPane jLayeredPane2;
    private javax.swing.JLayeredPane jLayeredPane3;
    private javax.swing.JLayeredPane jLayeredPane4;
    private javax.swing.JLayeredPane jLayeredPane5;
    private javax.swing.JLayeredPane jLayeredPane6;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JMenuItem lihatDaftarPaket;
    private javax.swing.JMenuItem lihatMember;
    private javax.swing.JMenuItem lihatPesanan;
    private javax.swing.JMenu member;
    private javax.swing.JMenu menuEdit;
    private javax.swing.JMenuItem order;
    private javax.swing.JMenu paket;
    private javax.swing.JMenuItem tambahMember;
    private javax.swing.JMenuItem tambahPaket;
    // End of variables declaration//GEN-END:variables
}
